
function UiMain(option)
  option = option or 'sale'

  local ts = require('ts')
  local cjson = ts.json

  local MyTable = UiMain_option_sel(option)

  local MyJsonString = cjson.encode(MyTable)
  UiVaPrintLog('UiMain - MyJsonString='..tostring(MyJsonString))
  -- UiVaPrintLog('112')
  -- RxLog('UiMain - MyJsonString='..tostring(MyJsonString))
  -- RxLog('12')

  -- local filePath =  RxDhFile:file_binary_path('UiMain')
  -- RxDhFile:file_write(filePath, MyTable)

  -- 测试--检测 table
  -- showUI(checkTable(MyTable))
  -- if true then return end

  -- 正式运行
  local UIret,values = showUI(MyJsonString)
  local valuesString = cjson.encode(values)
  RxLog('UiMain - UIret='..tostring(UIret).. '--values='..tostring(valuesString))

  UiVaUpdateTableValue(values)

  UiVaPrintLog('--1---------------')
  UiVaPrintLog('--2---------------')
  UiVaPrintLog('--3---------------')
  local MyUiVa = cjson.encode(UiVa)

  if UIret == 1 and RxDeviceScale() == 1 then
    -- 启动脚本
    UiVaPrintLog('UiVa='..tostring(MyUiVa))
    UiVaPrintLog('UiVa - > string end')
    UiVaPrintLog('------------------- 启动游戏 ----------')
    UiVaPrintLog('rdo='..tostring(UiVa.ui.rdo))
    UiVaPrintLog('dh_saveday='..tostring(UiVa.ui.dh_saveday))

    RxJugeUI()
    UiVaPrintLog('游戏停止运行')
    lua_exit()
  else
    UiVaPrintLog('------------------- 脚本退出 ----------')
    lua_exit()
  end
end

function UiMain_option_sel(option)
  local cnOpt = {
    main = 'rxsgs_mjz_main.dat',
    root = 'rxsgs_mjz_root.dat',
    freetask = 'rxsgs_mjz_free_task.dat',
  }

  local tabTitles = ''
  if option == 'freetask' then
    tabTitles = '多号,单号,日常任务,活动,注意事项'
  else
    tabTitles = '多号,单号,敦煌设置,日常任务,活动,注意事项'
  end

  local configName = cnOpt[option]
  UiVaPrintLog('UiMain_option_sel configName='..tostring(configName)..' tabTitles='..tostring(tabTitles))

  local rxShouUI = UiCore:UITable(configName, tabTitles)

  local ui = nil

  if option == 'freetask' then
    ui = UiCore:addUI(nil, {
      UiTabYouka(option),
      UiTabFunc(option),
      UiTabUsual(option),
      UiTabActivity(option),
      UiCore:pageDocoment(),
    })
  else
    ui = UiCore:addUI(nil, {
      UiTabYouka(option),
      UiTabFunc(option),
      UiTabDh(option),
      UiTabUsual(option),
      UiTabActivity(option),
      UiCore:pageDocoment(),
    })
  end

  rxShouUI.pages = ui

  return rxShouUI
end